﻿using System;
using System.Windows.Forms;
using System.Drawing;
using Bakındur.Properties;

namespace Bakındur
{
    class Program
    {
        static SozlukIcon icon;
        static System.Threading.Mutex instance;
        static Sozluk sozluk;

        [STAThread()]
        static int Main()
        {
            bool ok;

            instance = new System.Threading.Mutex(true, "Bakındur Sözlük", out ok);//Yeni örneği çallıştırılmasın diye
            if (!ok)
            {
                MessageBox.Show("Bakındur Sözlük çalışıyor...", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return 0;
            }

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

            using (sozluk = new Sozluk())
            {
                using (icon = new SozlukIcon(sozluk))
                {
                    Application.EnableVisualStyles();
                    Application.Run();
                }
            }

            GC.KeepAlive(instance);
            return 0;
        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            MessageBox.Show(string.Format("Hata oluştu.{0}{1}", System.Environment.NewLine, e.Exception.Message), "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        public static void ApplyTheme()
        {
            sozluk.ApplyTheme();
        }
    }
}
